﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LsKeyboardCore
{
    public class ColorUtil
    {
        /// <summary>
        /// 亮,按比例增加
        /// </summary>
        /// <param name="c"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static Color Light(Color c, float scale = 0.5f)
        {
            scale = Math.Abs(scale);
            return Color.FromArgb(c.A, Math.Min(255, (int)(c.R * (1 + scale))), Math.Min(255, (int)(c.G * (1 + scale))), Math.Min(255, (int)(c.B * (1 + scale))));
        }
        /// <summary>
        /// 暗,按比例减少
        /// </summary>
        /// <param name="c"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static Color Dark(Color c, float scale = 0.5f)
        {
            scale = Math.Abs(scale);
            return Color.FromArgb(c.A, Math.Max(0, (int)(c.R * (1 - scale))), Math.Max(0, (int)(c.G * (1 - scale))), Math.Max(0, (int)(c.B * (1 - scale))));
        }

        /// <summary>
        /// 获取颜色指定透明度的新颜色
        /// </summary>
        /// <param name="c"></param>
        /// <param name="a"></param>
        /// <returns></returns>
        public static Color Lucency(Color c, int a = 128)
        {
            return Color.FromArgb(a, c.R, c.G, c.B);
        }
    }
}
